<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\ding;

use cores\BaseModel;

/**
 * 用户收货地址模型
 * Class UserAddress
 * @package app\common\model
 */
class ClerkMember extends BaseModel {
	// 定义表名
	protected $name = 'ding_clerk_member';

	// 定义主键
	protected $pk = 'id';

	/**
	 * 追加字段
	 * @var array
	 */
	protected $append = ['role_text', 'sex_label','last_day'];

	public static function detail($where, array $with = []) {
		return static::get($where, $with);
	}
	public function getLastDayAttr($value, $data) {
		$day=time()-$data['last_time'];
		$day=$day/86400;
		$day=floor($day);

		return $day;
	}
	public function getUpdateTimeAttr($value, $data) {

		return Date('Y-m-d', $value);
	}
	public function getLastTimeAttr($value, $data) {

		return Date('Y-m-d', $value);
	}
	public function getSexLabelAttr($value, $data) {
		switch ($data['sex']) {
		case 1:
			$sex = '先生';
			break;
		case 2:
			$sex = '女士';
			break;
		default:
			$sex = '';
			break;
		}
		return $sex;
	}
	public function getRoleTextAttr($value, $data) {
		switch ($data['role']) {
		case 1:
			$role = '普通';
			break;
		case 2:
			$role = '重要';
			break;
		case 3:
			$role = '核心';
			break;

		default:
			$role = '散客';
			break;
		}
		return $role;
	}

}
